use threadpool::ThreadPool;
use std::sync::mpsc::channel;

pub fn test() {
    let n_workers = 4;
    let n_jobs = 8;
    let pool = ThreadPool::new(n_workers);

    let (tx, rx) = channel();
    for i in 0..n_jobs {
        let tx = tx.clone();
        pool.execute(move|| {
            if i % 2 == 0 {
                tx.send(1).expect("channel will be there waiting for the pool");
            }
        });
    }
    for i in rx.iter() {
        println!("{}", i);
    }
}